package org.metasketch.graphics.language.xml;

import java.io.FileReader;

import com.thoughtworks.xstream.XStream;

public class GraphicsReader {

	public static GraphicNotation read(String path) throws Throwable {

		XStream xstream = new XStream();
		xstream.autodetectAnnotations(true);

		xstream.processAnnotations(GraphicNotation.class);
		xstream.processAnnotations(Constant.class);
		xstream.processAnnotations(CustomImage.class);
		xstream.processAnnotations(CustomStyle.class);
		xstream.processAnnotations(Slot.class);
		xstream.processAnnotations(Binding.class);
		xstream.processAnnotations(Graphic.class);
		xstream.processAnnotations(Node.class);
		xstream.processAnnotations(StyleVar.class);

		// xstream.processAnnotations(GraphicNotation.class);

		// basic aliases
		// xstream.alias("graphic-notation", GraphicNotation.class);
		// xstream.alias("constant", Constant.class);
		//
		// xstream.alias("image", CustomImage.class);
		// xstream.alias("style", CustomStyle.class);
		// xstream.alias("slot", Slot.class);
		// xstream.alias("binding", Binding.class);
		//
		// xstream.alias("graphic", Graphic.class);
		// xstream.alias("node", Node.class);

		// field configs
		// xstream.

		// xstream.alias("constant", Constant.class);
		// xstream.alias("constant", Constant.class);

		FileReader reader = new FileReader(path);
		GraphicNotation notation = (GraphicNotation) xstream.fromXML(reader);

		return notation;

	}

}
